package leetcodecompetition.S109;

import org.junit.jupiter.api.Test;

/**
 * @Author: Siantar
 * @Date: 2023-07-22-23:04
 * @Description: 1.0
 */
public class T6931 {
    public long maxScore(int[] nums, int x) {
        long a = Integer.MIN_VALUE, b = Integer.MIN_VALUE, n = nums.length;
        if (nums[0] % 2 == 0) {
            a = nums[0];
        } else {
            b = nums[0];
        }
        for (int i = 1; i < n; i++) {
            if (nums[i] % 2 == 0) {
                a = Math.max(a, b-x)+nums[i];
            } else {
                b = Math.max(b, a-x)+nums[i];
            }
        }
        return Math.max(a, b);
    }

    @Test
    public void test() {
        System.out.println(maxScore(new int[]{2, 3, 6, 1, 9, 2}, 5));
    }
}
